
/*
Charles S. Bullock, III, William D. Hicks, 
    M.V. Hood, III, Seth C. McKee, and Daniel A. Smith
   "The Election of African American State Legislators in the Modern South" in LSQ
*/

/*
.DO file created by William D. Hicks (hickswd@appstate.edu)

It reproduces TABLES 2-3 and FIGURES 2 in the main manuscript. It also reproduces
Table C1 and FIGURES B1-C1 in Online Appendix.  
 
Last update to this file: 3/15/2020 
This file directs the following tasks:
   (1) label/define variables
   (2) reproduce MODELS for TABLE 2
   (3) reporoduce TABLE 2 in a .CSV file 
       - TABLE_2.csv
   (4) reporoduce estimates for FIGURE 2
   (5) reproduce Figure 2 in a .pdf
       - FIGURE_2.pdf
   (6) reproduce estimates in TABLE 3
   (7) reproduce TABLE 3 in TWO .CSV files
       - TABLE_3A.csv
	   - TABLE_3B.csv
   (8) reproduce FIGURES B1 and B2 in Appendix as .pdf files
       - FIGURE_B1.pdf
	   - FIGURE_B2.pdf
   (9) reproduce estimates in TABLE C1
   (10) reproduce TABLE C1 in a .CSV file
       - TABLE_C1.csv
   (11) reproduce alternative estimates for TABLE C1
   (12) reproduce alternative table C1 in a .CSV file 
       - TABLE_C1_V2.csv
   (13) reproduce estimates for FIGURE C1
   (14) reproduce FIGURE C1 in .pdf
        - FIGURE_C1.pdf 

*/

/*
                 YOU NEED TO FIRST IMPORT THE .DTA DATASET (see line 372, too)
                 THIS REQUIRES THAT YOU WRITE YOUR OWN PATH
*/

use ~[FILE PATH]/REPLICATION_DATA_LEGISLATORS_FULL.dta, clear 

/*
NOTE: YOU NEED TO RELOAD THESE RAW DATA ON LINE ~372, SO COPY YOUR PATH 
THERE TOO. 
*/

/*
            OUTPUT (ALL TABLES & GRAPHS) SAVED TO ~DIRECTORY
    -you also need to set the appropriate location for a directory file - 
*/

cd [MAKE YOUR DIRECTORY HERE]


/*                           
                    VARIABLE DEFINITIONS AND LABELS
*/

label var state_code "Unique state identifier" 
label var state_abr "State Abbreviation" 
label var dist_name "Name of state legislative district, where appropriate" 
label var dist_number "Number for the state legislative district" 
label var senate "Chamber of district (senate=1, house=0)" 
label var mmd "Multimember district (0,1)" 
label var dist_post "District post position that identifies geographic locale" 
label var dist_post_mmd "District post position that identifies a post in multimember district" 
label var redist "District was redistricted or changed since last election" 
label var election_year "Year of election for district" 
label var election_regime "Election period (1993-95; 2003-05; 2013-15) for district" 
label var elect_black "District elects a black lawmaker (0,1)" 
label var deep_south "District is in the Deep South (0,1)" 
label var black1pop "Percentage of district's population that is black"  
label var open_seat "District had an open seat (0,1)"
label var contested "District had an election in which a major party candidate lost" 
label var contested_old "District election featured more than one candidate" 
label var global_time "Yearly Counter (election_year-1971)" 
label var maj_min "Majority Black District (0,1)" 



				
				

/* ESTIMATES FOR MODEL 1, TABLE 2 */

 
qui melogit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested ///
				mmd senate redist ///
				c.global_time c.global_time#c.global_time ///
				|| state_chamber: || dist_id_unique: , difficult iterate(10)
 
estimates store M1


/* ESTIMATES FOR MODEL 2, TABLE 2 */

qui melogit elect_black i.maj_min i.deep_south i.maj_min#i.deep_south ///
				open_seat contested ///
				mmd senate redist ///
				c.global_time c.global_time#c.global_time ///
				|| state_chamber: || dist_id_unique: , 

estimates store M2
		

/* TABLE 2 */
esttab M1 M2 using TABLE_2.csv, replace ar2 ///
 nonumbers mtitles("M1" "M2" "M3") cells(b(star fmt(4)) se(par fmt(4))) ///
 starlevels(+ 0.10 * 0.05 ** 0.01) stats(N aic bic, ///
 fmt(%9.0g %9.3f)) varwidth(30) modelwidth(10) ///
 title("Multilevel Logit: Election of Black Lawmakers") ///
 note("Note: DV = 1 for black lawmaker elected, 0 otherwise") ///
 varlabels(_cons Constant black1pop "% of Population Black" ///
 1.deep_south "Deep South"  ///
 1.deep_south#c.black1pop "% of Population Black X Deep South" ///
 1.maj_min "Majority Minority District" ///
 1.maj_min#1.deep_south "Majority Minority X Deep South" ///
 open_seat "Open Seat" ///
 contested "Contested Election" ///
 mmd "Multimember District" ///
 senate "Senate" global_time "Year Counter (1968=0)" ///
 c.global_time#c.global_time "Year Counter Squared") ///
 order(black1pop 1.deep_south 1.maj_min 1.deep_south#c.black1pop ///
 1.maj_min#1.deep_south) ///
 drop(0.deep_south 0.deep_south#c.black1pop 0.maj_min ///
 0.maj_min#0.deep_south 0.maj_min#1.deep_south 1.maj_min#0.deep_south) ///
 legend style(tab) 			
							
			
				

/* 
       POPULATION-AVERAGED PREDICTIONS FIT TO MODEL 1, PRESENTED IN FIGURE 2
 */
estimates restore M1
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=0 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=3) predict(mu) saving(tab_rimsouth_70s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=1 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=3) predict(mu) saving(tab_deepsouth_70s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=0 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=13) predict(mu) saving(tab_rimsouth_80s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=1 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=13) predict(mu) saving(tab_deepsouth_80s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=0 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=23) predict(mu) saving(tab_rimsouth_90s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=1 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=23) predict(mu) saving(tab_deepsouth_90s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=0 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=33) predict(mu) saving(tab_rimsouth_00s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=1 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=33) predict(mu) saving(tab_deepsouth_00s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=0 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=43) predict(mu) saving(tab_rimsouth_10s_full, replace)
quietly margins, level(90) at(black1pop=(0(10)100) deep_south=1 senate=0 mmd=0 open_seat=0 contested=1 redist=0 global_time=43) predict(mu) saving(tab_deepsouth_10s_full, replace)



/*
FIGURE 2 
NOTE: FIGURE REQUIRES THE USER WRITTEN PROGRAM combomarginsplot
*/

combomarginsplot tab_rimsouth_70s_full tab_rimsouth_80s_full tab_rimsouth_90s_full tab_rimsouth_00s_full tab_rimsouth_10s_full, ///
   labels("1974" "1984" "1994" "2004" "2014") ///
   xlabel(0(5)100, labsize(small)) ///
   ylabel(, nogrid labsize(small)) ///
   title("") ///
   xtitle("Districts' Black Population (percentage)", size(small)) ///
   ytitle("Pr(Black Lawmaker|Rim-South)", size(small)) ///
   noci ///
   file1opts(msymbol(oh) lpattern(solid) lwidth(thin)) ///
   file2opts(msymbol(dh) lpattern(dash) lwidth(thin)) ///
   file3opts(msymbol(th) lpattern(shortdash_dot) lwidth(thin)) ///
   file4opts(msymbol(sh) lpattern(longdash_dot) lwidth(thin)) ///
   fileci1opts(lwidth(vthin)) ///
   fileci2opts(lwidth(vthin)) ///
   fileci3opts(lwidth(vthin)) ///
   fileci4opts(lwidth(vthin)) ///
   yline(0.5, lwidth(vthin) lpattern(dash) lcolor(red)) ///
   xline(50, lwidth(vthin) lpattern(dash) lcolor(red)) ///
   scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
   saving(FIGURE_2A, replace)
   
   
combomarginsplot tab_deepsouth_70s_full tab_deepsouth_80s_full tab_deepsouth_90s_full tab_deepsouth_00s_full tab_deepsouth_10s_full, ///
   labels("1974" "1984" "1994" "2004" "2014") ///
   xlabel(0(5)100, labsize(small)) ///
   ylabel(, nogrid labsize(small)) ///
   title("") ///
   xtitle("Districts' Black Population (percentage)", size(small)) ///
   ytitle("Pr(Black Lawmaker|Deep-South)", size(small)) ///
   noci ///
   file1opts(msymbol(oh) lpattern(solid) lwidth(thin)) ///
   file2opts(msymbol(dh) lpattern(dash) lwidth(thin)) ///
   file3opts(msymbol(th) lpattern(shortdash_dot) lwidth(thin)) ///
   file4opts(msymbol(sh) lpattern(longdash_dot) lwidth(thin)) ///
   fileci1opts(lwidth(vthin)) ///
   fileci2opts(lwidth(vthin)) ///
   fileci3opts(lwidth(vthin)) ///
   fileci4opts(lwidth(vthin)) ///
   yline(0.5, lwidth(vthin) lpattern(dash) lcolor(red)) ///
   xline(50, lwidth(vthin) lpattern(dash) lcolor(red)) ///
   scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
   saving(FIGURE_2B, replace)
   
gr combine FIGURE_2B.gph FIGURE_2A.gph, col(2) scheme(s1mono) ycommon
graph export FIGURE_2.pdf, replace



/* TABLE 3. TABLE OF PREDICTIVE MARGINS*/


use tab_rimsouth_70s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_70s 
rename _ci_lb ll_70s
rename _ci_ub ul_70s
order black_pop PR_Black_70s ll_70s ul_70s
save tab_rimsouth_70s.dta, replace

use tab_rimsouth_80s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_80s 
rename _ci_lb ll_80s
rename _ci_ub ul_80s
order black_pop PR_Black_80s ll_80s ul_80s
save tab_rimsouth_80s.dta, replace

use tab_rimsouth_90s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_90s 
rename _ci_lb ll_90s
rename _ci_ub ul_90s
order black_pop PR_Black_90s ll_90s ul_90s
save tab_rimsouth_90s.dta, replace

use tab_rimsouth_00s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_00s 
rename _ci_lb ll_00s
rename _ci_ub ul_00s
order black_pop PR_Black_00s ll_00s ul_00s
save tab_rimsouth_00s.dta, replace

use tab_rimsouth_10s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_10s 
rename _ci_lb ll_10s
rename _ci_ub ul_10s
order black_pop PR_Black_10s ll_10s ul_10s
save tab_rimsouth_10s.dta, replace

use tab_rimsouth_70s, clear
merge 1:1 black_pop using tab_rimsouth_80s.dta
drop _merge
merge 1:1 black_pop using tab_rimsouth_90s.dta
drop _merge
merge 1:1 black_pop using tab_rimsouth_00s.dta
drop _merge
merge 1:1 black_pop using tab_rimsouth_10s.dta
drop _merge 

drop ll_* 
drop ul_*

export excel using TABLE_3B.xlsx, firstrow(variables) replace 

use tab_deepsouth_70s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_70s 
rename _ci_lb ll_70s
rename _ci_ub ul_70s
order black_pop PR_Black_70s ll_70s ul_70s
save tab_deepsouth_70s.dta, replace

use tab_deepsouth_80s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_80s 
rename _ci_lb ll_80s
rename _ci_ub ul_80s
order black_pop PR_Black_80s ll_80s ul_80s
save tab_deepsouth_80s.dta, replace

use tab_deepsouth_90s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_90s 
rename _ci_lb ll_90s
rename _ci_ub ul_90s
order black_pop PR_Black_90s ll_90s ul_90s
save tab_deepsouth_90s.dta, replace

use tab_deepsouth_00s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_00s 
rename _ci_lb ll_00s
rename _ci_ub ul_00s
order black_pop PR_Black_00s ll_00s ul_00s
save tab_deepsouth_00s.dta, replace

use tab_deepsouth_10s_full.dta, clear
gen black_pop = (_at-1)*10
format _ci_lb %8.4fc 
format _margin %8.4fc 
format _ci_ub %8.4fc 
keep black_pop _margin _ci_lb _ci_ub
rename _margin PR_Black_10s 
rename _ci_lb ll_10s
rename _ci_ub ul_10s
order black_pop PR_Black_10s ll_10s ul_10s
save tab_deepsouth_10s.dta, replace

use tab_deepsouth_70s, clear
merge 1:1 black_pop using tab_deepsouth_80s.dta
drop _merge
merge 1:1 black_pop using tab_deepsouth_90s.dta
drop _merge
merge 1:1 black_pop using tab_deepsouth_00s.dta
drop _merge
merge 1:1 black_pop using tab_deepsouth_10s.dta
drop _merge 

drop ll_* 
drop ul_*

export excel using TABLE_3A.xlsx, firstrow(variables) replace 




/* APPENDIX REPLICATION CODE */

/*
                 RELOAD RAW DATASEAT
*/

use ~[FILE PATH]/REPLICATION_DATA_LEGISLATORS_FULL.dta, clear 

keep if election_regime !=. 


/*                           
                    VARIABLE DEFINITIONS AND LABELS
*/

label var state_code "Unique state identifier" 
label var state_abr "State Abbreviation" 
label var dist_name "Name of state legislative district, where appropriate" 
label var dist_number "Number for the state legislative district" 
label var senate "Chamber of district (senate=1, house=0)" 
label var mmd "Multimember district (0,1)" 
label var dist_post "District post position that identifies geographic locale" 
label var dist_post_mmd "District post position that identifies a post in multimember district" 
label var redist "District was redistricted or changed since last election" 
label var election_year "Year of election for district" 
label var election_regime "Election period (1993-95; 2003-05; 2013-15) for district" 
label var elect_black "District elects a black lawmaker (0,1)" 
label var deep_south "District is in the Deep South (0,1)" 
label var black1pop "Percentage of district's population that is black"  
label var open_seat "District had an open seat (0,1)"
label var contested "District had an election in which a major party candidate lost" 
label var contested_old "District election featured more than one candidate" 
label var global_time "Yearly Counter (election_year-1971)" 
label var maj_min "Majority Black District (0,1)" 



/* list of cases */
*tab chamber_year



/* FIGURES B1 and B2. BOX PLOTS*/
		
gen black1pop_ds = black1pop
replace black1pop_ds = . if deep_south==0
lab var black1pop_ds "Deep South" 

gen black1pop_rs = black1pop
replace black1pop_rs = . if deep_south==1
lab var black1pop_rs "Rim South" 

gen black1pop_ws = black1pop
lab var black1pop_ws "All South" 

		
graph box black1pop_ws black1pop_ds black1pop_rs if senate==1, ///
     box(1, col(gs1) ) box(2, col(gs7)) box(3, col(gs13)) ///
     marker(1, mcolor(gs2=1)) marker(2, mcolor(gs7)) marker(3, mcolor(gs13)) ///
     over(election_regime) ///
     scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
	 legend(cols(3)) 
graph export FIGURE_B2.pdf, replace
	 
graph box black1pop_ws black1pop_ds black1pop_rs if senate==0, ///
     box(1, col(gs1) ) box(2, col(gs7)) box(3, col(gs13)) ///
     marker(1, mcolor(gs2=1)) marker(2, mcolor(gs7)) marker(3, mcolor(gs13)) ///
     over(election_regime) ///
     scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
	 legend(cols(3)) 
graph export FIGURE_B1.pdf, replace



	 


/************** MODELS FOR TABLE C1 **********************/

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested_old ///
				mmd senate if election_regime==0   
estimates store M1970s

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested_old ///
				mmd senate if election_regime==1   
estimates store M1980s

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested_old ///
				mmd senate if election_regime==2   
estimates store M1990s

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested_old ///
				senate if election_regime==3   
estimates store M2000s

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested_old ///
				senate if election_regime==4   
estimates store M2010s

 /* TABLE C1 */
 
 esttab M1970s M1980s M1990s M2000s M2010s using TABLE_C1.csv, ar2 replace ///
   nonumber ///
   mtitles("1973-75" "1983--85" "1993--1995" "2003--05" "2013--15" ) ///
   varlabels(_cons Constant black1pop "% of Population Black" ///
   1.deep_south "Deep South"  ///
   1.deep_south#c.black1pop "% of Population Black X Deep South" ///
   open_seat "Open Seat" ///
   contested_old "Contested Election" ///
   mmd "Multimember District" ///
   senate "Senate" ) ///
   drop(0.deep_south 0.deep_south#c.black1pop) ///
   order(black1pop 1.deep_south 1.deep_south#c.black1pop) ///
   cells(b(star fmt(4)) se(par fmt(4))) starlevels(+ 0.10 * 0.05 ** 0.01) ///
   stats(N aic bic) ///
   varwidth(35) style()
   
   /************** MODELS FOR TABLE C1 
          ALTERNATIVE CONTESTED ELECTION VARIABLE **********************/

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested ///
				mmd senate if election_regime==0   
estimates store M1970s_v2

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested ///
				mmd senate if election_regime==1   
estimates store M1980s_v2

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested ///
				mmd senate if election_regime==2   
estimates store M1990s_v2

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested ///
				senate if election_regime==3   
estimates store M2000s_v2

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
				open_seat contested ///
				senate if election_regime==4   
estimates store M2010s_v2

 /* TABLE C1 */
 
 esttab M1970s_v2 M1980s_v2 M1990s_v2 M2000s_v2 M2010s_v2 using TABLE_C1_V2.csv, ar2 replace ///
   nonumber ///
   mtitles("1973-75" "1983--85" "1993--1995" "2003--05" "2013--15" ) ///
   varlabels(_cons Constant black1pop "% of Population Black" ///
   1.deep_south "Deep South"  ///
   1.deep_south#c.black1pop "% of Population Black X Deep South" ///
   open_seat "Open Seat" ///
   contested_old "Contested Election" ///
   mmd "Multimember District" ///
   senate "Senate" ) ///
   drop(0.deep_south 0.deep_south#c.black1pop) ///
   order(black1pop 1.deep_south 1.deep_south#c.black1pop) ///
   cells(b(star fmt(4)) se(par fmt(4))) starlevels(+ 0.10 * 0.05 ** 0.01) ///
   stats(N aic bic) ///
   varwidth(35) style()
   
 /*************** ESTIMATES FOR FIGURE C1 **************************/

/* 

NOTE:REQUIRES USER WRITTEN PROGRAM combomarginsplot

*/
   

estimates restore M1970s
quietly margins, at(black1pop=(0(5)100) deep_south=0 senate=0 mmd=0 open_seat=0 contested=1) saving(margins_black_1974_rimsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=1 senate=0 mmd=0 open_seat=0 contested=1) saving(margins_black_1974_deepsouth, replace)

quietly margins, dydx(deep_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) saving(margins_deepsouth_1974, replace)   
   
estimates restore M1980s
quietly margins, at(black1pop=(0(5)100) deep_south=0 senate=0 mmd=0 open_seat=0 contested=1) saving(margins_black_1984_rimsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=1 senate=0 mmd=0 open_seat=0 contested=1) saving(margins_black_1984_deepsouth, replace)

quietly margins, dydx(deep_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) saving(margins_deepsouth_1984, replace)	

estimates restore M1990s
quietly margins, at(black1pop=(0(5)100) deep_south=0 senate=0 mmd=0 open_seat=0 contested=1) saving(margins_black_1994_rimsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=1 senate=0 mmd=0 open_seat=0 contested=1) saving(margins_black_1994_deepsouth, replace)

quietly margins, dydx(deep_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) saving(margins_deepsouth_1994, replace)	

estimates restore M2000s
quietly margins, at(black1pop=(0(5)100) deep_south=0 senate=0 open_seat=0 contested=1) saving(margins_black_2000_rimsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=1 senate=0 open_seat=0 contested=1) saving(margins_black_2000_deepsouth, replace)

quietly margins, dydx(deep_south) at(black1pop=(0(5)100) senate=0 open_seat=0 contested=1) saving(margins_deepsouth_2000, replace)	

estimates restore M2010s
quietly margins, at(black1pop=(0(5)100) deep_south=0 senate=0 open_seat=0 contested=1) saving(margins_black_2010_rimsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=1 senate=0 open_seat=0 contested=1) saving(margins_black_2010_deepsouth, replace)

quietly margins, dydx(deep_south) at(black1pop=(0(5)100) senate=0 open_seat=0 contested=1) saving(margins_deepsouth_2010, replace)	


/*FIGURE C1*/

combomarginsplot margins_black_1974_deepsouth margins_black_1984_deepsouth margins_black_1994_deepsouth margins_black_2000_deepsouth margins_black_2010_deepsouth, ///
   labels("1973-75" "1983-85" "1993-95" "2003-05" "2013-15") ///
   xlabel(0(5)100, labsize(small)) ///
   ylabel(, nogrid labsize(small)) ///
   title("") ///
   xtitle("Districts' Black Population (percentage)", size(small)) ///
   ytitle("Pr(Black Lawmaker|Deep-South)", size(small)) ///
   noci ///
   file1opts(msymbol(oh) lpattern(solid) lwidth(thin)) ///
   file2opts(msymbol(dh) lpattern(dash) lwidth(thin)) ///
   file3opts(msymbol(th) lpattern(shortdash_dot) lwidth(thin)) ///
   file4opts(msymbol(sh) lpattern(longdash_dot) lwidth(thin)) ///
   fileci1opts(lwidth(vthin)) ///
   fileci2opts(lwidth(vthin)) ///
   fileci3opts(lwidth(vthin)) ///
   fileci4opts(lwidth(vthin)) ///
   yline(0.5, lwidth(vthin) lpattern(dash) lcolor(red)) ///
   xline(50, lwidth(vthin) lpattern(dash) lcolor(red)) ///
   scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
   saving(FIGURE_C1A, replace)
   
   
combomarginsplot margins_black_1974_rimsouth margins_black_1984_rimsouth margins_black_1994_rimsouth margins_black_2000_rimsouth margins_black_2010_rimsouth, ///
   labels("1973-75" "1983-85" "1993-95" "2003-05" "2013-15") ///
   xlabel(0(5)100, labsize(small)) ///
   ylabel(, nogrid labsize(small)) ///
   title("") ///
   xtitle("Districts' Black Population (percentage)", size(small)) ///
   ytitle("Pr(Black Lawmaker|Rim-South)", size(small)) ///
   noci ///
   file1opts(msymbol(oh) lpattern(solid) lwidth(thin)) ///
   file2opts(msymbol(dh) lpattern(dash) lwidth(thin)) ///
   file3opts(msymbol(th) lpattern(shortdash_dot) lwidth(thin)) ///
   file4opts(msymbol(sh) lpattern(longdash_dot) lwidth(thin)) ///
   fileci1opts(lwidth(vthin)) ///
   fileci2opts(lwidth(vthin)) ///
   fileci3opts(lwidth(vthin)) ///
   fileci4opts(lwidth(vthin)) ///
   yline(0.5, lwidth(vthin) lpattern(dash) lcolor(red)) ///
   xline(50, lwidth(vthin) lpattern(dash) lcolor(red)) ///
   scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
   saving(FIGURE_C1B, replace)
   
gr combine FIGURE_C1A.gph FIGURE_C1B.gph, col(2) scheme(s1mono) ycommon
graph export FIGURE_C1.pdf, replace





